# -*- coding: utf-8 -*-


class Observer(object):

    def __init__(self, name, sub):
        self.name = name
        self.sub = sub

    def update(self):
        pass


class StockObserver(Observer):
    # no need to rewrite __init__()
    def update(self):
        print "{}:{},stop watching Stock and go on work!".format(self.name, self.sub.action)


class NBAObserver(Observer):
    def update(self):
        print "{}:{},stop watching NBA and go on work!".format(self.name, self.sub.action)


class SecretaryBase:
    def __init__(self):
        self.observers = []

    def attach(self, new_observer):
        pass

    def notify(self):
        pass


class Secretary(SecretaryBase):
    def attach(self, new_observer):
        self.observers.append(new_observer)

    def notify(self):
        for p in self.observers:
            p.update()


if __name__ == "__main__":
    p = Secretary()
    s1 = StockObserver("xh", p)
    s2 = NBAObserver("wyt", p)
    p.attach(s1)
    p.attach(s2)
    p.action = "WARNING:BOSS"
    p.notify()
